package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.system.domain.vo.YearStatResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MdjfCaseMain;
import com.ruoyi.system.service.IMdjfCaseMainService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 矛盾纠纷--案件主事件Controller
 * 
 * @author ruoyi
 * @date 2025-03-28
 */
@Api("矛盾纠纷--案件主事件管理")
@RestController
@RequestMapping("/system/main")
public class MdjfCaseMainController extends BaseController
{
    @Autowired
    private IMdjfCaseMainService mdjfCaseMainService;

    /**
     * 查询矛盾纠纷--案件主事件列表
     */
    @ApiOperation("查询参数列表")
    @PreAuthorize("@ss.hasPermi('system:main:list')")
    @DataScope(deptAlias = "m", userAlias = "m")
    @GetMapping("/list")
    public TableDataInfo list(MdjfCaseMain mdjfCaseMain)
    {
        startPage();
        List<MdjfCaseMain> list = mdjfCaseMainService.selectMdjfCaseMainList(mdjfCaseMain);
        return getDataTable(list);
    }

    /**
     * 导出矛盾纠纷--案件主事件列表
     */
    @ApiOperation("导出参数列表")
//    @PreAuthorize("@ss.hasPermi('system:main:export')")
    @Log(title = "矛盾纠纷--案件主事件", businessType = BusinessType.EXPORT)
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    @PostMapping("/export")
    public void export(HttpServletResponse response, MdjfCaseMain mdjfCaseMain)
    {
        List<MdjfCaseMain> list = mdjfCaseMainService.selectMdjfCaseMainList(mdjfCaseMain);
        ExcelUtil<MdjfCaseMain> util = new ExcelUtil<MdjfCaseMain>(MdjfCaseMain.class);
        util.exportExcel(response, list, "矛盾纠纷--案件主事件数据");
    }

    /**
     * 获取矛盾纠纷--案件主事件详细信息
     */
    @ApiOperation("获取事件详细信息")
//    @PreAuthorize("@ss.hasPermi('system:main:query')")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    @GetMapping(value = "/{caseMainId}")
    public AjaxResult getInfo(@PathVariable("caseMainId") Long caseMainId)
    {
        return success(mdjfCaseMainService.selectMdjfCaseMainByCaseMainId(caseMainId));
    }

    /**
     * 新增矛盾纠纷--案件主事件
     */
    @ApiOperation("新增事件")
//    @PreAuthorize("@ss.hasPermi('system:main:add')")
    @Log(title = "矛盾纠纷--案件主事件", businessType = BusinessType.INSERT)
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    @PostMapping
    public AjaxResult add(@RequestBody MdjfCaseMain mdjfCaseMain)
    {
        return toAjax(mdjfCaseMainService.insertMdjfCaseMain(mdjfCaseMain));
    }

    /**
     * 修改矛盾纠纷--案件主事件
     */
    @ApiOperation("修改事件")
//    @PreAuthorize("@ss.hasPermi('system:main:edit')")
    @Log(title = "矛盾纠纷--案件主事件", businessType = BusinessType.UPDATE)
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    @PutMapping
    public AjaxResult edit(@RequestBody MdjfCaseMain mdjfCaseMain)
    {
        return toAjax(mdjfCaseMainService.updateMdjfCaseMain(mdjfCaseMain));
    }

    /**
     * 删除矛盾纠纷--案件主事件
     */
    @ApiOperation("删除事件")
//    @PreAuthorize("@ss.hasPermi('system:main:remove')")
    @Log(title = "矛盾纠纷--案件主事件", businessType = BusinessType.DELETE)
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
	@DeleteMapping("/{caseMainIds}")
    public AjaxResult remove(@PathVariable Long[] caseMainIds)
    {
        return toAjax(mdjfCaseMainService.deleteMdjfCaseMainByCaseMainIds(caseMainIds));
    }

    /**
     * 获取矛盾纠纷--案件主事件登记撤回
     */
    @ApiOperation("案件主事件登记撤回")
//    @PreAuthorize("@ss.hasPermi('system:main:query')")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    @PutMapping(value = "/withdraw")
    public AjaxResult withdraw(@RequestBody MdjfCaseMain mdjfCaseMain)
    {
        return success(mdjfCaseMainService.withdraw(mdjfCaseMain));
    }

    /**
     * 获取矛盾纠纷--案件主事件受理
     */
    @ApiOperation("案件主事件受理")
//    @PreAuthorize("@ss.hasPermi('system:main:query')")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    @PutMapping(value = "/accept")
    public AjaxResult accept(@RequestBody MdjfCaseMain mdjfCaseMain)
    {
        return success(mdjfCaseMainService.accept(mdjfCaseMain));
    }


    /**
     * 获取矛盾纠纷--案件主事件处理包含回访
     */
    @ApiOperation("案件主事件 处理")
//    @PreAuthorize("@ss.hasPermi('system:main:query')")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    @PutMapping(value = "/dispose")
    public AjaxResult dispose(@RequestBody MdjfCaseMain mdjfCaseMain)
    {
        return success(mdjfCaseMainService.dispose(mdjfCaseMain));
    }


    /**
     * 矛盾纠纷--案件主事件回访
     */
    @ApiOperation("案件主事件 回访")
//    @PreAuthorize("@ss.hasPermi('system:main:query')")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    @PutMapping(value = "/disposereturn")
    public AjaxResult disposereturn(@RequestBody MdjfCaseMain mdjfCaseMain)
    {
        return success(mdjfCaseMainService.disposereturn(mdjfCaseMain));
    }


    /**
     * 矛盾纠纷--案件主事件督办
     */
    @ApiOperation("督办事件")
//    @PreAuthorize("@ss.hasPermi('system:main:remove')")
    @Log(title = "矛盾纠纷--案件主事件", businessType = BusinessType.DELETE)
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    @GetMapping("/supervising/{caseMainIds}")
    public AjaxResult supervisingIds(@PathVariable Long[] caseMainIds)
    {
        return toAjax(mdjfCaseMainService.supervisingIds(caseMainIds));
    }


    /**
     * 矛盾纠纷--案件主事件年度统计
     * @param year
     * @return
     */
    @GetMapping("/seeYear/{year}")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult getYearStat(
            @PathVariable(value = "year") Integer year) {
        return success(mdjfCaseMainService.getYearStat(year));
    }

    /**
     * 矛盾纠纷--案件主事件日统计 按每日统计  2021-05-11
     * @param day
     * @return
     */
    @GetMapping("/seeDay/{day}")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult getDayStat(
            @PathVariable(value = "day") String day) {
        return success(mdjfCaseMainService.getDayDeptStat(day));
    }

    /**
     * 矛盾纠纷--近期案件处理走势图
     * @param
     * @return
     */
    @GetMapping("/recentTrend")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult recentTrend() {
        return success(mdjfCaseMainService.recentTrend());
    }

    /**
     * 矛盾纠纷--首页 案件处理分析
     * @param
     * @return
     */
    @GetMapping("/handleAnalytics")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult handleAnalytics() {
        return success(mdjfCaseMainService.handleAnalytics());
            }


    /**
     * 矛盾纠纷--今日部门案件办理情况  2021-05-11
     * @param day
     * @return
     */
    @GetMapping("/caseHandling/{day}")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult getCaseHandling(
            @PathVariable(value = "day") String day) {
        return success(mdjfCaseMainService.getCaseHandling(day));
    }

    /**
     * 矛盾纠纷--近期案件诉求量增长率分析
     * @param
     * @return
     */
    @GetMapping("/casesGrow")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult casesGrow() {
        return success(mdjfCaseMainService.casesGrow());
    }


    /**
     * 矛盾纠纷--近期案件处理数
     * @param
     * @return
     */
    @GetMapping("/casesDispose")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult casesDispose() {
        return success(mdjfCaseMainService.casesDispose());
    }


    /**
     * 矛盾纠纷--区域案件数
     * @param
     * @return
     */
    @GetMapping("/casesRegion")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    public AjaxResult casesRegion() {
        return success(mdjfCaseMainService.casesRegion());
    }

}
